//https://www.nowcoder.com/practice/70e00e490b454006976c1fdf47f155d9?tpId=46&tqId=38907&rp=1&ru=/ta/classic-code&qru=/ta/classic-code&difficulty=1&judgeStatus=&tags=/question-ranking
class LCA {
  public:
    int getLCA(int a, int b) {
        // write code here
        while (a != 1 && b != 1) {
            if (a > b)
                swap(a, b); //b永远大于a
            if (b % 2 == 1) { //为奇数
                b = (b - 1) / 2;
            } else {
                b = b / 2;
            }
            if (a == b)
                return a;
        }
        return 1;
    }
};

//https://www.nowcoder.com/practice/845ec89145b04b2b855d020d9c3ea2ef?tpId=46&tqId=38918&rp=1&ru=/ta/classic-code&qru=/ta/classic-code&difficulty=1&judgeStatus=&tags=/question-ranking
class Exchange {
public:
    vector<int> exchangeAB(vector<int> AB) {
        // write code here
        AB[0] ^= AB[1];
        AB[1] ^= AB[0];
        AB[0] ^= AB[1];
        return AB;
    }
};

//https://www.nowcoder.com/practice/b0a82250677a4fabb0bc41053fa05013?tpId=46&tqId=38920&rp=1&ru=/ta/classic-code&qru=/ta/classic-code&difficulty=1&judgeStatus=&tags=/question-ranking
class Max {
  public:
    int getMax(int a, int b) {
        // write code here
        int c = a - b;
        c >>= 31;
        c &= 1;//获得符号位
        return a - (a - b) * c;
    }
};